Repository navigation
feat(gax): implement inScope() in OpenTelemetryTracingTracer - #15033
jinseopkim0 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the inScope() method in OpenTelemetryTracingTracer to activate the current span (either the active attempt span or the overall operation span) on the calling thread's OpenTelemetry context. It also marks the operationSpan and attemptSpan fields as volatile to ensure thread safety. Additionally, comprehensive unit tests have been added to verify the correct behavior of inScope() and to ensure that there are no context leaks across threads. There are no review comments, and I have no feedback to provide.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces thread-safe span activation in OpenTelemetryTracingTracer by marking operationSpan and attemptSpan as volatile, implementing the inScope() method to manage OpenTelemetry scopes, and adding corresponding unit tests to verify scope fallback and multithreaded isolation. The reviewer suggests replacing the multiple volatile variables with an explicit lock (such as ReentrantLock) to guard the shared state, ensuring consistency and atomic updates across threads.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces thread safety to the OpenTelemetryTracingTracer class by using a ReentrantLock to synchronize access to operationSpan and attemptSpan. It also implements the inScope() method to activate the current span on the OpenTelemetry context, along with corresponding unit tests to verify behavior in single-threaded and multi-threaded scenarios. The review feedback recommends making the returned Scope in inScope() idempotent to prevent potential context leaks or corruption from multiple close() calls.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces thread-safety improvements to OpenTelemetryTracingTracer by utilizing a ReentrantLock to synchronize access to the operation and attempt spans. It also implements the inScope() method to manage the active OpenTelemetry context safely across threads, backed by new unit tests verifying scope activation, fallback behavior, and thread isolation. The review feedback recommends optimizing the inScope() implementation by replacing the AtomicBoolean with an anonymous class using a primitive boolean flag to avoid unnecessary object allocations on the critical path.
…TracingTracer.inScope()
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces thread-safe span management in OpenTelemetryTracingTracer by adding a ReentrantLock and helper methods to guard access to attemptSpan and operationSpan. It also implements the inScope() method to safely activate the current span and adds comprehensive unit tests to verify scope behavior, fallback logic, and multithreaded execution. The reviewer recommends ensuring that all other methods in the class accessing these spans are updated to use the new thread-safe helper methods to prevent potential data races.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces thread safety to OpenTelemetryTracingTracer by adding a ReentrantLock to guard access to operationSpan and attemptSpan. It also implements the inScope() method to activate the current span on the calling thread's OpenTelemetry context, and adds corresponding unit tests to verify scope activation, fallback behavior, and multithreaded execution safety. As there are no review comments, we have no additional feedback to provide.
…latile implementation
|
|





Implements
ApiTracer.inScope()inOpenTelemetryTracingTracer(withvolatileoperationSpanandattemptSpanfields) to activate the current attempt span on the calling thread's OpenTelemetryContext, falling back to the operation span when no attempt is in flight.Because
GrpcClientCalls.newCallalready enterstracer.inScope(), this also links downstreamgrpc-javaclient spans to GAX's attempt span automatically.b/499388983
b/570676007